package com.kaijie.controller;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.kaijie.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.kaijie.entity.RoomSortInfnEntity;
import com.kaijie.service.RoomSortInfnService;
import com.kaijie.utils.PageUtils;
import com.kaijie.utils.R;



/**
 * 
 *
 * @author Jy
 * @email 846021119@qq.com
 * @date 2022-02-28 12:02:21
 */
@RestController
@RequestMapping("kaijie/roomsortinfn")
public class RoomSortInfnController {
    @Autowired
    private RoomSortInfnService roomSortInfnService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("kaijie:roomsortinfn:list")
    public Map<String, Object> list(@RequestParam Map<String, Object> params){
        List<RoomSortInfnEntity> roomSortInfnEntityList=roomSortInfnService.list();
        Map<String, Object> map = new HashMap<>();
        map.put("code",0);
        map.put("count",roomSortInfnEntityList.size());
        map.put("msg"," ");
        map.put("data",roomSortInfnEntityList);
        return map;
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{rsid}")
    @RequiresPermissions("kaijie:roomsortinfn:info")
    public R info(@PathVariable("rsid") Integer rsid){
        RoomSortInfnEntity roomSortInfn = roomSortInfnService.getById(rsid);

        return R.ok().put("roomSortInfn", roomSortInfn);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("kaijie:roomsortinfn:save")
    public R save(@RequestBody RoomSortInfnEntity roomSortInfn){
        roomSortInfnService.save(roomSortInfn);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("kaijie:roomsortinfn:update")
    public R update(@RequestBody RoomSortInfnEntity roomSortInfn){
        ValidatorUtils.validateEntity(roomSortInfn);
        roomSortInfnService.updateById(roomSortInfn);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("kaijie:roomsortinfn:delete")
    public R delete(@RequestBody Integer[] rsids){
        roomSortInfnService.removeByIds(Arrays.asList(rsids));

        return R.ok();
    }

    @GetMapping ("/listRoomSortInfn")
    public Object RoomSortInfnList(){
        List<RoomSortInfnEntity> r=roomSortInfnService.list();
        Map<String, Object> map = new HashMap<>();
        map.put("code",0);
        map.put("count",r.size());
        map.put("msg"," ");
        map.put("data",r);
        return map;
    }

}
